package settingsapp.settings.toggle;

import ece.settingsapp.R;
import android.content.Context;
import android.content.Intent;

public class SettingAirplaneMode extends ToggleSettingChanger
{
	public SettingAirplaneMode(Context context, int intRepresentation)
	{
		super(context, intRepresentation);
		this.context = context;
	}
	
	protected void setValue(boolean value)
	{
		android.provider.Settings.System.putInt(context.getContentResolver(),
				android.provider.Settings.System.AIRPLANE_MODE_ON, value ? 1 : 0);
		Intent intent = new Intent(Intent.ACTION_AIRPLANE_MODE_CHANGED);
		intent.putExtra("state", true);
		context.sendBroadcast(intent);
	}

	@Override
	public void readValue()
	{
		isOn = (android.provider.Settings.System.getInt(context.getContentResolver(),
			android.provider.Settings.System.AIRPLANE_MODE_ON, isOn ? 1 : 0) != 0);
	}

	@Override
	public int getResourceOn()
	{
		return R.drawable.airplane_on;
	}

	@Override
	public int getResourceOff()
	{
		return R.drawable.airplane_off;
	}
}
